Learn R Programming

MXM (version 0.9.5)

Regression models fitting: Regression modelling

Description

Generic regression modelling function.

Usage

reg.fit(y, dataset, event = NULL, reps = NULL, group = NULL, slopes = FALSE, reml = FALSE, model = NULL, robust = FALSE, wei = NULL, xnew = NULL)

Arguments

y
The target (dependent) variable. It can be a numerical variable, factor, ordinal factor, percentages, matrix, or time to event. If the values are proportions or percentages, i.e. strictly within 0 and 1 they are mapped into R using log( target/(1 - target) ). If they are compositional data the additive log-ratio (multivariate logit) transformation is aplied beforehand.
dataset
The indendent variable(s). It can be a vector, a matrix or a dataframe with continuous only variables, a data frame with mixed or only categorical variables.
event
This is NULL unless you have time to event data (survival regression).
reps
This is NULL unless you have time measurements (longitudinal data).
group
This is NULL unless you have grouped (or clustered) data or longitudinal data (is the latter case the arugment reps is required).
slopes
This is for the longitudinal data only, TRUE or FALSE. Should random slopes be added or not?
reml
This is for the longitudinal or grouped data only, TRUE or FALSE. If TRUE, REML will be used, otherwise ML will be used.
model
The type of model you want to use. It can be specified by the user or left NULL, if other correct arguments have been passed. Poissible values (apart from NULL) are: "gaussian" (default), "binary", "binomial", "multinomial", "poisson", "ordinal", "Cox", "weibull", "exponential", "zip0", "zipx", "beta", "median", "negbin", "longitudinal" and "grouped". The "zip0" means that the zero part is constant, the variables are not associated with the excessive zeros. This is done with "zipx". The value "grouped" refers to grouped data, but this does not have to be given if the argument "group" is given, but not the argument "reps. The "binomial" is when you have the number of successes and also the number of trials.
robust
A boolean variable. If TRUE robust models will be returned. Currently this is supported by the "gaussian" model only.
wei
A vector of weights to be used for weighted regression. The default value is NULL. We suggest not to use weights if you choose testIndReg and robust = TRUE (robust regression via M estimation)
xnew
If you have new data whose target values you want to predict put it here, otherwise leave it blank.

Value

A list including: A list including:

Details

This is a generic regression function, which offers prediction as well. It is important that you pass the arguments with their names, for example if you have time to event data, write "event = ..." and not just put your event variable. This will avoid confusion.

References

Almost the same as in CondIndTests.

See Also

ridge.reg, ses.model, mmpc.model

Examples

Run this code
#simulate a dataset with continuous data
dataset <- matrix(runif(100 * 10, 1, 100), nrow = 100 ) 
#the target feature is the last column of the dataset as a vector
target <- dataset[, 1]
dataset <- dataset[, -1]
a <- reg.fit(target, dataset)

Run the code above in your browser using DataLab